<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>兑换码列表</title>
    <link rel="stylesheet" href="${base}/layui/css/layui.css">
    <link rel="stylesheet" href="${base}/awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="${base}/css/formSelects-v4.css">
    <link rel="stylesheet" href="${base}/css/admin.css">
    <style>
    	.layui-bg-black{        width: 200px;height: 136px;margin-right: 30px;float: left;text-align: center;font-size: 33px;color: #000000!important;padding-top: 30px;}
    	.hide {display: none;}
    	.checkbox{display: inline-block;}
    	.layui-form-item{font-size: 18px;}
    	.width100 {width: 100px; margin-right: 30px;float: left;}
    	.width180 {width: 180px; margin-right: 20px;float: left;}
    	.layui-input { display: inline-block; }
    </style>
</head>
<body class="layui-layout-body" style="overflow:scroll;">
<#include "/common/left.flt">	
<div class="layui-main" style="position: absolute;left: 204px;top: 4px; width: calc(100% - 210px);" >
	<fieldset class="layui-elem-field layui-field-title" >
	  <legend>操作提示</legend>
	</fieldset>
	<div class="layui-form hide" id="discuss" style="padding-top:20px;padding-right:20px;">
		<div class="layui-form-item layui-form-text">
		    <label class="layui-form-label">会员天数</label>
		    <div class="layui-input-block">
		      <input name="days" id="days" type="number"  placeholder="开放会员天数" class="layui-input" value="0"/>
		    </div>
		</div>
		<div class="layui-form-item layui-form-text">
		    <label class="layui-form-label">赠送热度</label>
		    <div class="layui-input-block">
		      <input name="hot" id="hot" type="number"  placeholder="赠送热度" class="layui-input" value="0"/>
		    </div>
		</div>
	    <div class="layui-form-item layui-form-text">
		    <label class="layui-form-label">标题</label>
		    <div class="layui-input-block">
		      <input name="title" id="title" placeholder="请输入标题" class="layui-input"/>
		    </div>
		  </div>
	</div>
	<blockquote class="layui-elem-quote layui-quote-nm">
	 	<button class="layui-btn" id="add"> <span class="fa fa-plus-square-o"></span> 新加</button>
	</blockquote> 
	
	<!-- 
	<blockquote class="layui-elem-quote layui-quote-nm">
	 	<form action="${base}/black_list/exchange_list" method="post" id="dataForm" >
	        <div class="layui-input-inline" >
	        	<button class="layui-btn" lay-submit=""> <span class="fa fa-search"></span> 查询</button>
	 		</div>
	    </form>
	</blockquote>
	 -->
	<table class="layui-table" >
		<thead>
	       <tr>
	       		<th>兑换码</th>
	            <th>标题</th>
	            <th>操作</th>
	        </tr>
	     </thead>
	     <tbody>
	     <#list list as one>
	     <tr>
	     	<td>${one.code?default('')}</td>
	     	<td>${one.title?default('')}</td>
	     	<td><a onclick="del(${one.id});" ><span class="fa fa-trash"></span></a></td>
	     </tr>
	     </#list>
	     </tbody>
	</table>
</div>
</body>
<script src="${base}/js/jquery-2.1.4.min.js" type="text/javascript"></script>
<script src="${base}/layui/layui.all.js"></script>
<script src="${base}/js/jquery.form.js"></script>
<script type="text/javascript">

$("#add").click(function (){
	layui.use('form', function() {
	    var form = layui.form;
	    form.render('select');
	});

	layer.open({
	    type: 1 ,
	    title: '新加', 
	    area: ['600px', '480px'],   //宽高
	    shade: 0.4,   //遮罩透明度
	    content: $("#discuss"),
	    btn: ['确定'], //按钮组
	    scrollbar: false ,//屏蔽浏览器滚动条
	    yes: function(index){
	    	var days = $("#days").val();
	    	var hot = $("#hot").val();
	    	var title = $("#title").val();
	    	$.post("${base}/black_list/exchange",
				   		{"days":days,"hot":hot,"title":title,"times":0},function(data){ 
				   			layer.alert(data);
				   			$("#discuss").hide();
				   			window.location.reload();
				   		}
			);
	    	
	        layer.close(index);
	        
	        $("#discuss").hide();
	    },
		cancel: function(){
			$("#discuss").hide();        
	    }
	});

});

function del(id){
	//询问框
	layer.confirm('确定要删除吗？', {
	  btn: ['确定'] //按钮
	}, function(){
		$.post("${base}/black_list/del_exchange",
		   		{"id":id},function(data){ 
		   			layer.alert(data);
		   			window.location.reload();
		   		}
		    );  
	});
}

</script>
</html>